<template>
  <div>
    <transition
      name="musicplay"
      enter-active-class="animated fadeInUp"
      leave-active-class="animated fadeOutDown"
    >
      <PlayBar
        v-if="currentSong && show"
        @audio-play-handler="$emit('audio-play-handler')"
        @audio-pause-handler="$emit('audio-pause-handler')"
        :currentSong="currentSong"
        :playing="playing"
        :currentTime="currentTime"
        :duration="duration"
        @click.native="show = false"
        @show-list="listshow = !listshow"
      ></PlayBar>
    </transition>
    <transition
      name="musicplay"
      enter-active-class="animated fadeInUp"
      leave-active-class="animated fadeOutDown"
    >
      <PlayPage
        v-if="currentSong && !show"
        @changeShow="show = true"
        :currentSong="currentSong"
        :playing="playing"
        :currentTime="currentTime"
        :duration="duration"
        @update:crut="$emit('update:crut', $event)"
        @audio-play-handler="$emit('audio-play-handler')"
        @audio-pause-handler="$emit('audio-pause-handler')"
        @next-song="$emit('next-song')"
        @prev-song="$emit('prev-song')"
        @radomplay="$emit('radomplay',$event)"
      ></PlayPage>
    </transition>
    <transition
      name="musicplay"
      enter-active-class="animated fadeInUp"
      leave-active-class="animated fadeOutDown"
    >
      <PlayList class="playlist" v-if="listshow" :currentSong="currentSong" :playing="playing" @updateCurrentSong="$emit('update:currentSong', $event)" :playlist="playlist"></PlayList>
    </transition>
  </div>
</template>

<script>
import PlayBar from "./PlayBar.vue";
import PlayPage from "./PlayPage.vue";
import PlayList from "./PlayList.vue";
export default {
  components: {
    PlayBar,
    PlayPage,
    PlayList,
  },
  props: {
    currentSong: Object,
    playing: Boolean,
    duration: Number,
    currentTime: Number,
    playlist:Array,
  },
  data: function () {
    return {
      show: true,
      listshow: false,
    };
  },
};
</script>

<style lang="less" scoped>
.animated {
  animation-duration: 0.5s;
}
</style>